<!-- HTML header for doxygen 1.8.20-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
	<meta http-equiv="X-UA-Compatible" content="IE=9"/>
	<meta name="generator" content="Doxygen 1.9.4"/>
	<meta name="viewport" content="width=device-width, initial-scale=1"/>
	<title>Raspberry Pi Pico SDK: include/hardware/spi.h Source File</title>
	<!-- <link href="tabs.css" rel="stylesheet" type="text/css"/> -->
	<script type="text/javascript" src="jquery.js"></script>
	<script type="text/javascript" src="dynsections.js"></script>
	<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
	<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
    <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
	<link href="doxygen.css" rel="stylesheet" type="text/css" />
	<link href="normalise.css" rel="stylesheet" type="text/css"/>
<link href="main.css" rel="stylesheet" type="text/css"/>
<link href="styles.css" rel="stylesheet" type="text/css"/>
</head>
<body>
	<div class="navigation-mobile">
		<div class="logo--mobile">
			<a href="/"><img src="logo-mobile.svg" alt="Raspberry Pi"></a>
		</div>
		<div class="navigation-toggle">
			<span class="line-1"></span>
			<span class="line-2">
				<p>Menu Toggle</p>
			</span>
			<span class="line-3"></span>
		</div>
	</div>
	<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
		<div class="logo">
			<a href="index.html"> <img src="logo.svg" alt="Raspberry Pi"></a>
			<span style="display: inline-block; margin-top: 10px;">
				v2.0.0
			</span>
		</div>
		<div class="navigation-footer">
			<img src="logo-mobile.svg" alt="Raspberry Pi">
			<a href="https://www.raspberrypi.com/" target="_blank">By Raspberry Pi Ltd</a>
		</div>
<!-- 		<div class="search">
			<form>
				<input type="search" name="search" id="search" placeholder="Search">
				<input type="submit" value="Search">
			</form>
		</div> -->
<!-- Generated by Doxygen 1.9.4 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('rp2__common_2hardware__spi_2include_2hardware_2spi_8h_source.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle"><div class="title">spi.h</div></div>
</div><!--header-->
<div class="contents">
<a href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span><span class="comment">/*</span></div>
<div class="line"><a id="l00002" name="l00002"></a><span class="lineno">    2</span><span class="comment"> * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.</span></div>
<div class="line"><a id="l00003" name="l00003"></a><span class="lineno">    3</span><span class="comment"> *</span></div>
<div class="line"><a id="l00004" name="l00004"></a><span class="lineno">    4</span><span class="comment"> * SPDX-License-Identifier: BSD-3-Clause</span></div>
<div class="line"><a id="l00005" name="l00005"></a><span class="lineno">    5</span><span class="comment"> */</span></div>
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno">    6</span> </div>
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno">    7</span><span class="preprocessor">#ifndef _HARDWARE_SPI_H</span></div>
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno">    8</span><span class="preprocessor">#define _HARDWARE_SPI_H</span></div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno">    9</span> </div>
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno">   10</span><span class="preprocessor">#include &quot;<a class="code" href="pico_8h.html">pico.h</a>&quot;</span></div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno">   11</span><span class="preprocessor">#include &quot;hardware/structs/spi.h&quot;</span></div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno">   12</span><span class="preprocessor">#include &quot;hardware/regs/dreq.h&quot;</span></div>
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno">   13</span> </div>
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno">   14</span><span class="comment">// PICO_CONFIG: PARAM_ASSERTIONS_ENABLED_HARDWARE_SPI, Enable/disable assertions in the hardware_spi module, type=bool, default=0, group=hardware_spi</span></div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno">   15</span><span class="preprocessor">#ifndef PARAM_ASSERTIONS_ENABLED_HARDWARE_SPI</span></div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno">   16</span><span class="preprocessor">#ifdef PARAM_ASSERTIONS_ENABLED_SPI </span><span class="comment">// backwards compatibility with SDK &lt; 2.0.0</span></div>
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno">   17</span><span class="preprocessor">#define PARAM_ASSERTIONS_ENABLED_HARDWARE_SPI PARAM_ASSERTIONS_ENABLED_SPI</span></div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno">   18</span><span class="preprocessor">#else</span></div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno">   19</span><span class="preprocessor">#define PARAM_ASSERTIONS_ENABLED_HARDWARE_SPI 0</span></div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno">   20</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno">   21</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno">   22</span> </div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno">   23</span><span class="preprocessor">#ifdef __cplusplus</span></div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno">   24</span><span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> {</div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno">   25</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno">   26</span> </div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno">   42</span><span class="comment">// PICO_CONFIG: PICO_DEFAULT_SPI, Define the default SPI for a board, min=0, max=1, default=Usually provided via board header, group=hardware_spi</span></div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno">   43</span><span class="comment">// PICO_CONFIG: PICO_DEFAULT_SPI_SCK_PIN, Define the default SPI SCK pin, min=0, max=29, default=Usually provided via board header, group=hardware_spi</span></div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno">   44</span><span class="comment">// PICO_CONFIG: PICO_DEFAULT_SPI_TX_PIN, Define the default SPI TX pin, min=0, max=29, default=Usually provided via board header, group=hardware_spi</span></div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno">   45</span><span class="comment">// PICO_CONFIG: PICO_DEFAULT_SPI_RX_PIN, Define the default SPI RX pin, min=0, max=29, default=Usually provided via board header, group=hardware_spi</span></div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno">   46</span><span class="comment">// PICO_CONFIG: PICO_DEFAULT_SPI_CSN_PIN, Define the default SPI CSN pin, min=0, max=29, default=Usually provided via board header, group=hardware_spi</span></div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno">   47</span> </div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno"><a class="line" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">   51</a></span><span class="keyword">typedef</span> <span class="keyword">struct </span>spi_inst <a class="code hl_typedef" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a>;</div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno">   52</span> </div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"><a class="line" href="group__hardware__spi.html#ga9d931d2e2e5b1dfd8d5f1dea80df4dbd">   59</a></span><span class="preprocessor">#define spi0 ((spi_inst_t *)spi0_hw)</span></div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno">   60</span> </div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"><a class="line" href="group__hardware__spi.html#ga3de59ab064bc9405b059edce4366c694">   67</a></span><span class="preprocessor">#define spi1 ((spi_inst_t *)spi1_hw)</span></div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno">   68</span> </div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno">   75</span><span class="preprocessor">#if !defined(PICO_DEFAULT_SPI_INSTANCE) &amp;&amp; defined(PICO_DEFAULT_SPI)</span></div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno">   76</span><span class="preprocessor">#define PICO_DEFAULT_SPI_INSTANCE() (__CONCAT(spi,PICO_DEFAULT_SPI))</span></div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno">   77</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno">   78</span> </div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno">   92</span><span class="preprocessor">#ifdef PICO_DEFAULT_SPI_INSTANCE</span></div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno">   93</span><span class="preprocessor">#define spi_default PICO_DEFAULT_SPI_INSTANCE()</span></div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno">   94</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno">   95</span> </div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno">  104</span><span class="preprocessor">#ifndef SPI_NUM</span></div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno">  105</span><span class="keyword">static_assert</span>(NUM_SPIS == 2, <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno"><a class="line" href="group__hardware__spi.html#ga39308f1ccde24d91e0075059b380dd3a">  106</a></span><span class="preprocessor">#define SPI_NUM(spi) ((spi) == spi1)</span></div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno">  107</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno">  108</span> </div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno">  117</span><span class="preprocessor">#ifndef SPI_INSTANCE</span></div>
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno">  118</span><span class="keyword">static_assert</span>(NUM_SPIS == 2, <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno"><a class="line" href="group__hardware__spi.html#gae1d6ac7c86e9f76d5c1a38c6dfd978b9">  119</a></span><span class="preprocessor">#define SPI_INSTANCE(num) ((num) ? spi1 : spi0)</span></div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno">  120</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno">  121</span> </div>
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno">  131</span><span class="preprocessor">#ifndef SPI_DREQ_NUM</span></div>
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno">  132</span><span class="keyword">static_assert</span>(<a class="code hl_enumvalue" href="group__hardware__dma.html#gga6f0a19defc495cfa6078364122266014a46641088908dd355dc82971e7c7fbd35">DREQ_SPI0_RX</a> == <a class="code hl_enumvalue" href="group__hardware__dma.html#gga6f0a19defc495cfa6078364122266014a4b8b13f940414660401a7b334d85b64b">DREQ_SPI0_TX</a> + 1, <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno">  133</span><span class="keyword">static_assert</span>(<a class="code hl_enumvalue" href="group__hardware__dma.html#gga6f0a19defc495cfa6078364122266014a04665a3e6a5c58a6cbf2d0fe1503cf00">DREQ_SPI1_RX</a> == <a class="code hl_enumvalue" href="group__hardware__dma.html#gga6f0a19defc495cfa6078364122266014a01d244742e157d2d2fb8e55b5fd6d81b">DREQ_SPI1_TX</a> + 1, <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno">  134</span><span class="keyword">static_assert</span>(<a class="code hl_enumvalue" href="group__hardware__dma.html#gga6f0a19defc495cfa6078364122266014a01d244742e157d2d2fb8e55b5fd6d81b">DREQ_SPI1_TX</a> == <a class="code hl_enumvalue" href="group__hardware__dma.html#gga6f0a19defc495cfa6078364122266014a4b8b13f940414660401a7b334d85b64b">DREQ_SPI0_TX</a> + 2, <span class="stringliteral">&quot;&quot;</span>);</div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno"><a class="line" href="group__hardware__spi.html#gaa470b3363ffe872bba90d31814d33baa">  135</a></span><span class="preprocessor">#define SPI_DREQ_NUM(spi, is_tx) (DREQ_SPI0_TX + SPI_NUM(spi) * 2 + !(is_tx))</span></div>
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno">  136</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno">  137</span> </div>
<div class="line"><a id="l00141" name="l00141"></a><span class="lineno"><a class="line" href="group__hardware__spi.html#ga9850de61d3f6dcacbfb4e5cc5a7d2951">  141</a></span><span class="keyword">typedef</span> <span class="keyword">enum</span> {</div>
<div class="line"><a id="l00142" name="l00142"></a><span class="lineno">  142</span>    SPI_CPHA_0 = 0,</div>
<div class="line"><a id="l00143" name="l00143"></a><span class="lineno">  143</span>    SPI_CPHA_1 = 1</div>
<div class="line"><a id="l00144" name="l00144"></a><span class="lineno">  144</span>} <a class="code hl_enumeration" href="group__hardware__spi.html#ga9850de61d3f6dcacbfb4e5cc5a7d2951">spi_cpha_t</a>;</div>
<div class="line"><a id="l00145" name="l00145"></a><span class="lineno">  145</span> </div>
<div class="line"><a id="l00149" name="l00149"></a><span class="lineno"><a class="line" href="group__hardware__spi.html#ga49a77d9a0320db6d3451a9dda2b8a24b">  149</a></span><span class="keyword">typedef</span> <span class="keyword">enum</span> {</div>
<div class="line"><a id="l00150" name="l00150"></a><span class="lineno">  150</span>    SPI_CPOL_0 = 0,</div>
<div class="line"><a id="l00151" name="l00151"></a><span class="lineno">  151</span>    SPI_CPOL_1 = 1</div>
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno">  152</span>} <a class="code hl_enumeration" href="group__hardware__spi.html#ga49a77d9a0320db6d3451a9dda2b8a24b">spi_cpol_t</a>;</div>
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno">  153</span> </div>
<div class="line"><a id="l00157" name="l00157"></a><span class="lineno"><a class="line" href="group__hardware__spi.html#gaa9e8effacf4291301048ef7df03d353e">  157</a></span><span class="keyword">typedef</span> <span class="keyword">enum</span> {</div>
<div class="line"><a id="l00158" name="l00158"></a><span class="lineno">  158</span>    SPI_LSB_FIRST = 0,</div>
<div class="line"><a id="l00159" name="l00159"></a><span class="lineno">  159</span>    SPI_MSB_FIRST = 1</div>
<div class="line"><a id="l00160" name="l00160"></a><span class="lineno">  160</span>} <a class="code hl_enumeration" href="group__hardware__spi.html#gaa9e8effacf4291301048ef7df03d353e">spi_order_t</a>;</div>
<div class="line"><a id="l00161" name="l00161"></a><span class="lineno">  161</span> </div>
<div class="line"><a id="l00162" name="l00162"></a><span class="lineno">  162</span><span class="comment">// ----------------------------------------------------------------------------</span></div>
<div class="line"><a id="l00163" name="l00163"></a><span class="lineno">  163</span><span class="comment">// Setup</span></div>
<div class="line"><a id="l00164" name="l00164"></a><span class="lineno">  164</span> </div>
<div class="line"><a id="l00178" name="l00178"></a><span class="lineno">  178</span>uint <a class="code hl_function" href="group__hardware__spi.html#ga1dba14fb5488b5e4a69b30678f774df0">spi_init</a>(<a class="code hl_typedef" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi, uint baudrate);</div>
<div class="line"><a id="l00179" name="l00179"></a><span class="lineno">  179</span> </div>
<div class="line"><a id="l00188" name="l00188"></a><span class="lineno">  188</span><span class="keywordtype">void</span> <a class="code hl_function" href="group__hardware__spi.html#gaf0c3a38c80cf84a80602755d7bac77e2">spi_deinit</a>(<a class="code hl_typedef" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi);</div>
<div class="line"><a id="l00189" name="l00189"></a><span class="lineno">  189</span> </div>
<div class="line"><a id="l00200" name="l00200"></a><span class="lineno">  200</span>uint <a class="code hl_function" href="group__hardware__spi.html#ga37f4c04ce4165ac8c129226336a0b66c">spi_set_baudrate</a>(<a class="code hl_typedef" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi, uint baudrate);</div>
<div class="line"><a id="l00201" name="l00201"></a><span class="lineno">  201</span> </div>
<div class="line"><a id="l00210" name="l00210"></a><span class="lineno">  210</span>uint <a class="code hl_function" href="group__hardware__spi.html#gaa295443736ab03ac882f2d9383cac139">spi_get_baudrate</a>(<span class="keyword">const</span> <a class="code hl_typedef" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi);</div>
<div class="line"><a id="l00211" name="l00211"></a><span class="lineno">  211</span> </div>
<div class="line"><a id="l00218" name="l00218"></a><span class="lineno"><a class="line" href="group__hardware__spi.html#ga88620398eae6e0f66b551be57a279273">  218</a></span><span class="keyword">static</span> <span class="keyword">inline</span> uint <a class="code hl_function" href="group__hardware__spi.html#ga88620398eae6e0f66b551be57a279273">spi_get_index</a>(<span class="keyword">const</span> <a class="code hl_typedef" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi) {</div>
<div class="line"><a id="l00219" name="l00219"></a><span class="lineno">  219</span>    invalid_params_if(HARDWARE_SPI, spi != <a class="code hl_define" href="group__hardware__spi.html#ga9d931d2e2e5b1dfd8d5f1dea80df4dbd">spi0</a> &amp;&amp; spi != <a class="code hl_define" href="group__hardware__spi.html#ga3de59ab064bc9405b059edce4366c694">spi1</a>);</div>
<div class="line"><a id="l00220" name="l00220"></a><span class="lineno">  220</span>    <span class="keywordflow">return</span> <a class="code hl_define" href="group__hardware__spi.html#ga39308f1ccde24d91e0075059b380dd3a">SPI_NUM</a>(spi);</div>
<div class="line"><a id="l00221" name="l00221"></a><span class="lineno">  221</span>}</div>
<div class="line"><a id="l00222" name="l00222"></a><span class="lineno">  222</span> </div>
<div class="line"><a id="l00223" name="l00223"></a><span class="lineno">  223</span><span class="keyword">static</span> <span class="keyword">inline</span> <a class="code hl_struct" href="structspi__hw__t.html">spi_hw_t</a> *spi_get_hw(<a class="code hl_typedef" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi) {</div>
<div class="line"><a id="l00224" name="l00224"></a><span class="lineno">  224</span>    <a class="code hl_function" href="group__hardware__spi.html#ga88620398eae6e0f66b551be57a279273">spi_get_index</a>(spi); <span class="comment">// check it is a hw spi</span></div>
<div class="line"><a id="l00225" name="l00225"></a><span class="lineno">  225</span>    <span class="keywordflow">return</span> (<a class="code hl_struct" href="structspi__hw__t.html">spi_hw_t</a> *)spi;</div>
<div class="line"><a id="l00226" name="l00226"></a><span class="lineno">  226</span>}</div>
<div class="line"><a id="l00227" name="l00227"></a><span class="lineno">  227</span> </div>
<div class="line"><a id="l00228" name="l00228"></a><span class="lineno">  228</span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keyword">const</span> <a class="code hl_struct" href="structspi__hw__t.html">spi_hw_t</a> *spi_get_const_hw(<span class="keyword">const</span> <a class="code hl_typedef" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi) {</div>
<div class="line"><a id="l00229" name="l00229"></a><span class="lineno">  229</span>    <a class="code hl_function" href="group__hardware__spi.html#ga88620398eae6e0f66b551be57a279273">spi_get_index</a>(spi);  <span class="comment">// check it is a hw spi</span></div>
<div class="line"><a id="l00230" name="l00230"></a><span class="lineno">  230</span>    <span class="keywordflow">return</span> (<span class="keyword">const</span> <a class="code hl_struct" href="structspi__hw__t.html">spi_hw_t</a> *)spi;</div>
<div class="line"><a id="l00231" name="l00231"></a><span class="lineno">  231</span>}</div>
<div class="line"><a id="l00232" name="l00232"></a><span class="lineno">  232</span> </div>
<div class="line"><a id="l00244" name="l00244"></a><span class="lineno"><a class="line" href="group__hardware__spi.html#ga137168d01d302239d52420ad4f895d44">  244</a></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__hardware__spi.html#ga137168d01d302239d52420ad4f895d44">spi_set_format</a>(<a class="code hl_typedef" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi, uint data_bits, <a class="code hl_enumeration" href="group__hardware__spi.html#ga49a77d9a0320db6d3451a9dda2b8a24b">spi_cpol_t</a> cpol, <a class="code hl_enumeration" href="group__hardware__spi.html#ga9850de61d3f6dcacbfb4e5cc5a7d2951">spi_cpha_t</a> cpha, __unused <a class="code hl_enumeration" href="group__hardware__spi.html#gaa9e8effacf4291301048ef7df03d353e">spi_order_t</a> order) {</div>
<div class="line"><a id="l00245" name="l00245"></a><span class="lineno">  245</span>    invalid_params_if(HARDWARE_SPI, data_bits &lt; 4 || data_bits &gt; 16);</div>
<div class="line"><a id="l00246" name="l00246"></a><span class="lineno">  246</span>    <span class="comment">// LSB-first not supported on PL022:</span></div>
<div class="line"><a id="l00247" name="l00247"></a><span class="lineno">  247</span>    invalid_params_if(HARDWARE_SPI, order != SPI_MSB_FIRST);</div>
<div class="line"><a id="l00248" name="l00248"></a><span class="lineno">  248</span>    invalid_params_if(HARDWARE_SPI, cpol != SPI_CPOL_0 &amp;&amp; cpol != SPI_CPOL_1);</div>
<div class="line"><a id="l00249" name="l00249"></a><span class="lineno">  249</span>    invalid_params_if(HARDWARE_SPI, cpha != SPI_CPHA_0 &amp;&amp; cpha != SPI_CPHA_1);</div>
<div class="line"><a id="l00250" name="l00250"></a><span class="lineno">  250</span> </div>
<div class="line"><a id="l00251" name="l00251"></a><span class="lineno">  251</span>    <span class="comment">// Disable the SPI</span></div>
<div class="line"><a id="l00252" name="l00252"></a><span class="lineno">  252</span>    uint32_t enable_mask = spi_get_hw(spi)-&gt;cr1 &amp; SPI_SSPCR1_SSE_BITS;</div>
<div class="line"><a id="l00253" name="l00253"></a><span class="lineno">  253</span>    <a class="code hl_function" href="group__hardware__base.html#gafd1c089df868d987daf95870b501c2ed">hw_clear_bits</a>(&amp;spi_get_hw(spi)-&gt;cr1, SPI_SSPCR1_SSE_BITS);</div>
<div class="line"><a id="l00254" name="l00254"></a><span class="lineno">  254</span> </div>
<div class="line"><a id="l00255" name="l00255"></a><span class="lineno">  255</span>    <a class="code hl_function" href="group__hardware__base.html#ga81b27e30abef56fe090d22fd8dfdbcc1">hw_write_masked</a>(&amp;spi_get_hw(spi)-&gt;cr0,</div>
<div class="line"><a id="l00256" name="l00256"></a><span class="lineno">  256</span>                    ((uint)(data_bits - 1)) &lt;&lt; SPI_SSPCR0_DSS_LSB |</div>
<div class="line"><a id="l00257" name="l00257"></a><span class="lineno">  257</span>                    ((uint)cpol) &lt;&lt; SPI_SSPCR0_SPO_LSB |</div>
<div class="line"><a id="l00258" name="l00258"></a><span class="lineno">  258</span>                    ((uint)cpha) &lt;&lt; SPI_SSPCR0_SPH_LSB,</div>
<div class="line"><a id="l00259" name="l00259"></a><span class="lineno">  259</span>        SPI_SSPCR0_DSS_BITS |</div>
<div class="line"><a id="l00260" name="l00260"></a><span class="lineno">  260</span>        SPI_SSPCR0_SPO_BITS |</div>
<div class="line"><a id="l00261" name="l00261"></a><span class="lineno">  261</span>        SPI_SSPCR0_SPH_BITS);</div>
<div class="line"><a id="l00262" name="l00262"></a><span class="lineno">  262</span> </div>
<div class="line"><a id="l00263" name="l00263"></a><span class="lineno">  263</span>    <span class="comment">// Re-enable the SPI</span></div>
<div class="line"><a id="l00264" name="l00264"></a><span class="lineno">  264</span>    <a class="code hl_function" href="group__hardware__base.html#ga625e737a57f12211cf1f634ca5095ae4">hw_set_bits</a>(&amp;spi_get_hw(spi)-&gt;cr1, enable_mask);</div>
<div class="line"><a id="l00265" name="l00265"></a><span class="lineno">  265</span>}</div>
<div class="line"><a id="l00266" name="l00266"></a><span class="lineno">  266</span> </div>
<div class="line"><a id="l00276" name="l00276"></a><span class="lineno"><a class="line" href="group__hardware__spi.html#ga127e4bf0fc1d7d271d2e9160c6e3b722">  276</a></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code hl_function" href="group__hardware__spi.html#ga127e4bf0fc1d7d271d2e9160c6e3b722">spi_set_slave</a>(<a class="code hl_typedef" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi, <span class="keywordtype">bool</span> slave) {</div>
<div class="line"><a id="l00277" name="l00277"></a><span class="lineno">  277</span>    <span class="comment">// Disable the SPI</span></div>
<div class="line"><a id="l00278" name="l00278"></a><span class="lineno">  278</span>    uint32_t enable_mask = spi_get_hw(spi)-&gt;cr1 &amp; SPI_SSPCR1_SSE_BITS;</div>
<div class="line"><a id="l00279" name="l00279"></a><span class="lineno">  279</span>    <a class="code hl_function" href="group__hardware__base.html#gafd1c089df868d987daf95870b501c2ed">hw_clear_bits</a>(&amp;spi_get_hw(spi)-&gt;cr1, SPI_SSPCR1_SSE_BITS);</div>
<div class="line"><a id="l00280" name="l00280"></a><span class="lineno">  280</span> </div>
<div class="line"><a id="l00281" name="l00281"></a><span class="lineno">  281</span>    <span class="keywordflow">if</span> (slave)</div>
<div class="line"><a id="l00282" name="l00282"></a><span class="lineno">  282</span>        <a class="code hl_function" href="group__hardware__base.html#ga625e737a57f12211cf1f634ca5095ae4">hw_set_bits</a>(&amp;spi_get_hw(spi)-&gt;cr1, SPI_SSPCR1_MS_BITS);</div>
<div class="line"><a id="l00283" name="l00283"></a><span class="lineno">  283</span>    <span class="keywordflow">else</span></div>
<div class="line"><a id="l00284" name="l00284"></a><span class="lineno">  284</span>        <a class="code hl_function" href="group__hardware__base.html#gafd1c089df868d987daf95870b501c2ed">hw_clear_bits</a>(&amp;spi_get_hw(spi)-&gt;cr1, SPI_SSPCR1_MS_BITS);</div>
<div class="line"><a id="l00285" name="l00285"></a><span class="lineno">  285</span> </div>
<div class="line"><a id="l00286" name="l00286"></a><span class="lineno">  286</span>    <span class="comment">// Re-enable the SPI</span></div>
<div class="line"><a id="l00287" name="l00287"></a><span class="lineno">  287</span>    <a class="code hl_function" href="group__hardware__base.html#ga625e737a57f12211cf1f634ca5095ae4">hw_set_bits</a>(&amp;spi_get_hw(spi)-&gt;cr1, enable_mask);</div>
<div class="line"><a id="l00288" name="l00288"></a><span class="lineno">  288</span>}</div>
<div class="line"><a id="l00289" name="l00289"></a><span class="lineno">  289</span> </div>
<div class="line"><a id="l00290" name="l00290"></a><span class="lineno">  290</span><span class="comment">// ----------------------------------------------------------------------------</span></div>
<div class="line"><a id="l00291" name="l00291"></a><span class="lineno">  291</span><span class="comment">// Generic input/output</span></div>
<div class="line"><a id="l00292" name="l00292"></a><span class="lineno">  292</span> </div>
<div class="line"><a id="l00299" name="l00299"></a><span class="lineno"><a class="line" href="group__hardware__spi.html#ga0d7c020fac16f57ee8f805000713e405">  299</a></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code hl_function" href="group__hardware__spi.html#ga0d7c020fac16f57ee8f805000713e405">spi_is_writable</a>(<span class="keyword">const</span> <a class="code hl_typedef" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi) {</div>
<div class="line"><a id="l00300" name="l00300"></a><span class="lineno">  300</span>    <span class="keywordflow">return</span> (spi_get_const_hw(spi)-&gt;sr &amp; SPI_SSPSR_TNF_BITS);</div>
<div class="line"><a id="l00301" name="l00301"></a><span class="lineno">  301</span>}</div>
<div class="line"><a id="l00302" name="l00302"></a><span class="lineno">  302</span> </div>
<div class="line"><a id="l00309" name="l00309"></a><span class="lineno"><a class="line" href="group__hardware__spi.html#ga20dcaa3037e92bbcbab50b8635f102ff">  309</a></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code hl_function" href="group__hardware__spi.html#ga20dcaa3037e92bbcbab50b8635f102ff">spi_is_readable</a>(<span class="keyword">const</span> <a class="code hl_typedef" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi) {</div>
<div class="line"><a id="l00310" name="l00310"></a><span class="lineno">  310</span>    <span class="keywordflow">return</span> (spi_get_const_hw(spi)-&gt;sr &amp; SPI_SSPSR_RNE_BITS);</div>
<div class="line"><a id="l00311" name="l00311"></a><span class="lineno">  311</span>}</div>
<div class="line"><a id="l00312" name="l00312"></a><span class="lineno">  312</span> </div>
<div class="line"><a id="l00319" name="l00319"></a><span class="lineno"><a class="line" href="group__hardware__spi.html#ga5623d0396207ccbd3faa64a5d4f397c3">  319</a></span><span class="keyword">static</span> <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code hl_function" href="group__hardware__spi.html#ga5623d0396207ccbd3faa64a5d4f397c3">spi_is_busy</a>(<span class="keyword">const</span> <a class="code hl_typedef" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi) {</div>
<div class="line"><a id="l00320" name="l00320"></a><span class="lineno">  320</span>    <span class="keywordflow">return</span> (spi_get_const_hw(spi)-&gt;sr &amp; SPI_SSPSR_BSY_BITS);</div>
<div class="line"><a id="l00321" name="l00321"></a><span class="lineno">  321</span>}</div>
<div class="line"><a id="l00322" name="l00322"></a><span class="lineno">  322</span> </div>
<div class="line"><a id="l00335" name="l00335"></a><span class="lineno"><a class="line" href="group__hardware__spi.html#gabb840d4e3db64ea70fad6bb740717910">  335</a></span><span class="keywordtype">int</span> <a class="code hl_function" href="group__hardware__spi.html#gabb840d4e3db64ea70fad6bb740717910">spi_write_read_blocking</a>(<a class="code hl_typedef" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi, <span class="keyword">const</span> uint8_t *src, uint8_t *dst, <span class="keywordtype">size_t</span> len);</div>
<div class="line"><a id="l00336" name="l00336"></a><span class="lineno">  336</span> </div>
<div class="line"><a id="l00348" name="l00348"></a><span class="lineno"><a class="line" href="group__hardware__spi.html#ga541ec2a1eee4c7fee2134a8415f3b4c8">  348</a></span><span class="keywordtype">int</span> <a class="code hl_function" href="group__hardware__spi.html#ga541ec2a1eee4c7fee2134a8415f3b4c8">spi_write_blocking</a>(<a class="code hl_typedef" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi, <span class="keyword">const</span> uint8_t *src, <span class="keywordtype">size_t</span> len);</div>
<div class="line"><a id="l00349" name="l00349"></a><span class="lineno">  349</span> </div>
<div class="line"><a id="l00365" name="l00365"></a><span class="lineno"><a class="line" href="group__hardware__spi.html#ga40ce84e76797f81872f12557e537fc48">  365</a></span><span class="keywordtype">int</span> <a class="code hl_function" href="group__hardware__spi.html#ga40ce84e76797f81872f12557e537fc48">spi_read_blocking</a>(<a class="code hl_typedef" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi, uint8_t repeated_tx_data, uint8_t *dst, <span class="keywordtype">size_t</span> len);</div>
<div class="line"><a id="l00366" name="l00366"></a><span class="lineno">  366</span> </div>
<div class="line"><a id="l00367" name="l00367"></a><span class="lineno">  367</span><span class="comment">// ----------------------------------------------------------------------------</span></div>
<div class="line"><a id="l00368" name="l00368"></a><span class="lineno">  368</span><span class="comment">// SPI-specific operations and aliases</span></div>
<div class="line"><a id="l00369" name="l00369"></a><span class="lineno">  369</span> </div>
<div class="line"><a id="l00370" name="l00370"></a><span class="lineno">  370</span><span class="comment">// FIXME need some instance-private data for select() and deselect() if we are going that route</span></div>
<div class="line"><a id="l00371" name="l00371"></a><span class="lineno">  371</span> </div>
<div class="line"><a id="l00386" name="l00386"></a><span class="lineno"><a class="line" href="group__hardware__spi.html#gad3b96ae828fec8af4b0617db7e904019">  386</a></span><span class="keywordtype">int</span> <a class="code hl_function" href="group__hardware__spi.html#gad3b96ae828fec8af4b0617db7e904019">spi_write16_read16_blocking</a>(<a class="code hl_typedef" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi, <span class="keyword">const</span> uint16_t *src, uint16_t *dst, <span class="keywordtype">size_t</span> len);</div>
<div class="line"><a id="l00387" name="l00387"></a><span class="lineno">  387</span> </div>
<div class="line"><a id="l00401" name="l00401"></a><span class="lineno"><a class="line" href="group__hardware__spi.html#gacff6be19b2de92a34b295597f3ae8572">  401</a></span><span class="keywordtype">int</span> <a class="code hl_function" href="group__hardware__spi.html#gacff6be19b2de92a34b295597f3ae8572">spi_write16_blocking</a>(<a class="code hl_typedef" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi, <span class="keyword">const</span> uint16_t *src, <span class="keywordtype">size_t</span> len);</div>
<div class="line"><a id="l00402" name="l00402"></a><span class="lineno">  402</span> </div>
<div class="line"><a id="l00420" name="l00420"></a><span class="lineno"><a class="line" href="group__hardware__spi.html#ga743b7fbdf120a1b5fc098145e3ce8eaf">  420</a></span><span class="keywordtype">int</span> <a class="code hl_function" href="group__hardware__spi.html#ga743b7fbdf120a1b5fc098145e3ce8eaf">spi_read16_blocking</a>(<a class="code hl_typedef" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi, uint16_t repeated_tx_data, uint16_t *dst, <span class="keywordtype">size_t</span> len);</div>
<div class="line"><a id="l00421" name="l00421"></a><span class="lineno">  421</span> </div>
<div class="line"><a id="l00428" name="l00428"></a><span class="lineno"><a class="line" href="group__hardware__spi.html#ga6241d6c368b1af1b83a12c1e75515486">  428</a></span><span class="keyword">static</span> <span class="keyword">inline</span> uint <a class="code hl_function" href="group__hardware__spi.html#ga6241d6c368b1af1b83a12c1e75515486">spi_get_dreq</a>(<a class="code hl_typedef" href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a> *spi, <span class="keywordtype">bool</span> is_tx) {</div>
<div class="line"><a id="l00429" name="l00429"></a><span class="lineno">  429</span>    <span class="keywordflow">return</span> <a class="code hl_define" href="group__hardware__spi.html#gaa470b3363ffe872bba90d31814d33baa">SPI_DREQ_NUM</a>(spi, is_tx);</div>
<div class="line"><a id="l00430" name="l00430"></a><span class="lineno">  430</span>}</div>
<div class="line"><a id="l00431" name="l00431"></a><span class="lineno">  431</span> </div>
<div class="line"><a id="l00432" name="l00432"></a><span class="lineno">  432</span><span class="preprocessor">#ifdef __cplusplus</span></div>
<div class="line"><a id="l00433" name="l00433"></a><span class="lineno">  433</span>}</div>
<div class="line"><a id="l00434" name="l00434"></a><span class="lineno">  434</span><span class="preprocessor">#endif</span></div>
<div class="line"><a id="l00435" name="l00435"></a><span class="lineno">  435</span> </div>
<div class="line"><a id="l00436" name="l00436"></a><span class="lineno">  436</span><span class="preprocessor">#endif</span></div>
<div class="ttc" id="agroup__hardware__base_html_ga625e737a57f12211cf1f634ca5095ae4"><div class="ttname"><a href="group__hardware__base.html#ga625e737a57f12211cf1f634ca5095ae4">hw_set_bits</a></div><div class="ttdeci">static __force_inline void hw_set_bits(io_rw_32 *addr, uint32_t mask)</div><div class="ttdoc">Atomically set the specified bits to 1 in a HW register.</div><div class="ttdef"><b>Definition:</b> address_mapped.h:135</div></div>
<div class="ttc" id="agroup__hardware__base_html_ga81b27e30abef56fe090d22fd8dfdbcc1"><div class="ttname"><a href="group__hardware__base.html#ga81b27e30abef56fe090d22fd8dfdbcc1">hw_write_masked</a></div><div class="ttdeci">static __force_inline void hw_write_masked(io_rw_32 *addr, uint32_t values, uint32_t write_mask)</div><div class="ttdoc">Set new values for a sub-set of the bits in a HW register.</div><div class="ttdef"><b>Definition:</b> address_mapped.h:171</div></div>
<div class="ttc" id="agroup__hardware__base_html_gafd1c089df868d987daf95870b501c2ed"><div class="ttname"><a href="group__hardware__base.html#gafd1c089df868d987daf95870b501c2ed">hw_clear_bits</a></div><div class="ttdeci">static __force_inline void hw_clear_bits(io_rw_32 *addr, uint32_t mask)</div><div class="ttdoc">Atomically clear the specified bits to 0 in a HW register.</div><div class="ttdef"><b>Definition:</b> address_mapped.h:145</div></div>
<div class="ttc" id="agroup__hardware__dma_html_gga6f0a19defc495cfa6078364122266014a01d244742e157d2d2fb8e55b5fd6d81b"><div class="ttname"><a href="group__hardware__dma.html#gga6f0a19defc495cfa6078364122266014a01d244742e157d2d2fb8e55b5fd6d81b">DREQ_SPI1_TX</a></div><div class="ttdeci">@ DREQ_SPI1_TX</div><div class="ttdoc">Select SPI1's TX FIFO as DREQ.</div><div class="ttdef"><b>Definition:</b> dreq.h:108</div></div>
<div class="ttc" id="agroup__hardware__dma_html_gga6f0a19defc495cfa6078364122266014a04665a3e6a5c58a6cbf2d0fe1503cf00"><div class="ttname"><a href="group__hardware__dma.html#gga6f0a19defc495cfa6078364122266014a04665a3e6a5c58a6cbf2d0fe1503cf00">DREQ_SPI1_RX</a></div><div class="ttdeci">@ DREQ_SPI1_RX</div><div class="ttdoc">Select SPI1's RX FIFO as DREQ.</div><div class="ttdef"><b>Definition:</b> dreq.h:109</div></div>
<div class="ttc" id="agroup__hardware__dma_html_gga6f0a19defc495cfa6078364122266014a46641088908dd355dc82971e7c7fbd35"><div class="ttname"><a href="group__hardware__dma.html#gga6f0a19defc495cfa6078364122266014a46641088908dd355dc82971e7c7fbd35">DREQ_SPI0_RX</a></div><div class="ttdeci">@ DREQ_SPI0_RX</div><div class="ttdoc">Select SPI0's RX FIFO as DREQ.</div><div class="ttdef"><b>Definition:</b> dreq.h:107</div></div>
<div class="ttc" id="agroup__hardware__dma_html_gga6f0a19defc495cfa6078364122266014a4b8b13f940414660401a7b334d85b64b"><div class="ttname"><a href="group__hardware__dma.html#gga6f0a19defc495cfa6078364122266014a4b8b13f940414660401a7b334d85b64b">DREQ_SPI0_TX</a></div><div class="ttdeci">@ DREQ_SPI0_TX</div><div class="ttdoc">Select SPI0's TX FIFO as DREQ.</div><div class="ttdef"><b>Definition:</b> dreq.h:106</div></div>
<div class="ttc" id="agroup__hardware__spi_html_ga0d7c020fac16f57ee8f805000713e405"><div class="ttname"><a href="group__hardware__spi.html#ga0d7c020fac16f57ee8f805000713e405">spi_is_writable</a></div><div class="ttdeci">static bool spi_is_writable(const spi_inst_t *spi)</div><div class="ttdoc">Check whether a write can be done on SPI device.</div><div class="ttdef"><b>Definition:</b> spi.h:299</div></div>
<div class="ttc" id="agroup__hardware__spi_html_ga127e4bf0fc1d7d271d2e9160c6e3b722"><div class="ttname"><a href="group__hardware__spi.html#ga127e4bf0fc1d7d271d2e9160c6e3b722">spi_set_slave</a></div><div class="ttdeci">static void spi_set_slave(spi_inst_t *spi, bool slave)</div><div class="ttdoc">Set SPI master/slave.</div><div class="ttdef"><b>Definition:</b> spi.h:276</div></div>
<div class="ttc" id="agroup__hardware__spi_html_ga137168d01d302239d52420ad4f895d44"><div class="ttname"><a href="group__hardware__spi.html#ga137168d01d302239d52420ad4f895d44">spi_set_format</a></div><div class="ttdeci">static void spi_set_format(spi_inst_t *spi, uint data_bits, spi_cpol_t cpol, spi_cpha_t cpha, __unused spi_order_t order)</div><div class="ttdoc">Configure SPI.</div><div class="ttdef"><b>Definition:</b> spi.h:244</div></div>
<div class="ttc" id="agroup__hardware__spi_html_ga1dba14fb5488b5e4a69b30678f774df0"><div class="ttname"><a href="group__hardware__spi.html#ga1dba14fb5488b5e4a69b30678f774df0">spi_init</a></div><div class="ttdeci">uint spi_init(spi_inst_t *spi, uint baudrate)</div><div class="ttdoc">Initialise SPI instances.</div><div class="ttdef"><b>Definition:</b> spi.c:21</div></div>
<div class="ttc" id="agroup__hardware__spi_html_ga20dcaa3037e92bbcbab50b8635f102ff"><div class="ttname"><a href="group__hardware__spi.html#ga20dcaa3037e92bbcbab50b8635f102ff">spi_is_readable</a></div><div class="ttdeci">static bool spi_is_readable(const spi_inst_t *spi)</div><div class="ttdoc">Check whether a read can be done on SPI device.</div><div class="ttdef"><b>Definition:</b> spi.h:309</div></div>
<div class="ttc" id="agroup__hardware__spi_html_ga37f4c04ce4165ac8c129226336a0b66c"><div class="ttname"><a href="group__hardware__spi.html#ga37f4c04ce4165ac8c129226336a0b66c">spi_set_baudrate</a></div><div class="ttdeci">uint spi_set_baudrate(spi_inst_t *spi, uint baudrate)</div><div class="ttdoc">Set SPI baudrate.</div><div class="ttdef"><b>Definition:</b> spi.c:42</div></div>
<div class="ttc" id="agroup__hardware__spi_html_ga39308f1ccde24d91e0075059b380dd3a"><div class="ttname"><a href="group__hardware__spi.html#ga39308f1ccde24d91e0075059b380dd3a">SPI_NUM</a></div><div class="ttdeci">#define SPI_NUM(spi)</div><div class="ttdoc">Returns the SPI number for a SPI instance.</div><div class="ttdef"><b>Definition:</b> spi.h:106</div></div>
<div class="ttc" id="agroup__hardware__spi_html_ga3de59ab064bc9405b059edce4366c694"><div class="ttname"><a href="group__hardware__spi.html#ga3de59ab064bc9405b059edce4366c694">spi1</a></div><div class="ttdeci">#define spi1</div><div class="ttdef"><b>Definition:</b> spi.h:67</div></div>
<div class="ttc" id="agroup__hardware__spi_html_ga40ce84e76797f81872f12557e537fc48"><div class="ttname"><a href="group__hardware__spi.html#ga40ce84e76797f81872f12557e537fc48">spi_read_blocking</a></div><div class="ttdeci">int spi_read_blocking(spi_inst_t *spi, uint8_t repeated_tx_data, uint8_t *dst, size_t len)</div><div class="ttdoc">Read from an SPI device.</div></div>
<div class="ttc" id="agroup__hardware__spi_html_ga49a77d9a0320db6d3451a9dda2b8a24b"><div class="ttname"><a href="group__hardware__spi.html#ga49a77d9a0320db6d3451a9dda2b8a24b">spi_cpol_t</a></div><div class="ttdeci">spi_cpol_t</div><div class="ttdoc">Enumeration of SPI CPOL (clock polarity) values.</div><div class="ttdef"><b>Definition:</b> spi.h:149</div></div>
<div class="ttc" id="agroup__hardware__spi_html_ga541ec2a1eee4c7fee2134a8415f3b4c8"><div class="ttname"><a href="group__hardware__spi.html#ga541ec2a1eee4c7fee2134a8415f3b4c8">spi_write_blocking</a></div><div class="ttdeci">int spi_write_blocking(spi_inst_t *spi, const uint8_t *src, size_t len)</div><div class="ttdoc">Write to an SPI device, blocking.</div></div>
<div class="ttc" id="agroup__hardware__spi_html_ga5623d0396207ccbd3faa64a5d4f397c3"><div class="ttname"><a href="group__hardware__spi.html#ga5623d0396207ccbd3faa64a5d4f397c3">spi_is_busy</a></div><div class="ttdeci">static bool spi_is_busy(const spi_inst_t *spi)</div><div class="ttdoc">Check whether SPI is busy.</div><div class="ttdef"><b>Definition:</b> spi.h:319</div></div>
<div class="ttc" id="agroup__hardware__spi_html_ga6241d6c368b1af1b83a12c1e75515486"><div class="ttname"><a href="group__hardware__spi.html#ga6241d6c368b1af1b83a12c1e75515486">spi_get_dreq</a></div><div class="ttdeci">static uint spi_get_dreq(spi_inst_t *spi, bool is_tx)</div><div class="ttdoc">Return the DREQ to use for pacing transfers to/from a particular SPI instance.</div><div class="ttdef"><b>Definition:</b> spi.h:428</div></div>
<div class="ttc" id="agroup__hardware__spi_html_ga743b7fbdf120a1b5fc098145e3ce8eaf"><div class="ttname"><a href="group__hardware__spi.html#ga743b7fbdf120a1b5fc098145e3ce8eaf">spi_read16_blocking</a></div><div class="ttdeci">int spi_read16_blocking(spi_inst_t *spi, uint16_t repeated_tx_data, uint16_t *dst, size_t len)</div><div class="ttdoc">Read from an SPI device.</div></div>
<div class="ttc" id="agroup__hardware__spi_html_ga88620398eae6e0f66b551be57a279273"><div class="ttname"><a href="group__hardware__spi.html#ga88620398eae6e0f66b551be57a279273">spi_get_index</a></div><div class="ttdeci">static uint spi_get_index(const spi_inst_t *spi)</div><div class="ttdoc">Convert SPI instance to hardware instance number.</div><div class="ttdef"><b>Definition:</b> spi.h:218</div></div>
<div class="ttc" id="agroup__hardware__spi_html_ga9850de61d3f6dcacbfb4e5cc5a7d2951"><div class="ttname"><a href="group__hardware__spi.html#ga9850de61d3f6dcacbfb4e5cc5a7d2951">spi_cpha_t</a></div><div class="ttdeci">spi_cpha_t</div><div class="ttdoc">Enumeration of SPI CPHA (clock phase) values.</div><div class="ttdef"><b>Definition:</b> spi.h:141</div></div>
<div class="ttc" id="agroup__hardware__spi_html_ga9d931d2e2e5b1dfd8d5f1dea80df4dbd"><div class="ttname"><a href="group__hardware__spi.html#ga9d931d2e2e5b1dfd8d5f1dea80df4dbd">spi0</a></div><div class="ttdeci">#define spi0</div><div class="ttdef"><b>Definition:</b> spi.h:59</div></div>
<div class="ttc" id="agroup__hardware__spi_html_gaa295443736ab03ac882f2d9383cac139"><div class="ttname"><a href="group__hardware__spi.html#gaa295443736ab03ac882f2d9383cac139">spi_get_baudrate</a></div><div class="ttdeci">uint spi_get_baudrate(const spi_inst_t *spi)</div><div class="ttdoc">Get SPI baudrate.</div><div class="ttdef"><b>Definition:</b> spi.c:76</div></div>
<div class="ttc" id="agroup__hardware__spi_html_gaa470b3363ffe872bba90d31814d33baa"><div class="ttname"><a href="group__hardware__spi.html#gaa470b3363ffe872bba90d31814d33baa">SPI_DREQ_NUM</a></div><div class="ttdeci">#define SPI_DREQ_NUM(spi, is_tx)</div><div class="ttdoc">Returns the dreq_num_t used for pacing DMA transfers to or from this SPI instance....</div><div class="ttdef"><b>Definition:</b> spi.h:135</div></div>
<div class="ttc" id="agroup__hardware__spi_html_gaa9e8effacf4291301048ef7df03d353e"><div class="ttname"><a href="group__hardware__spi.html#gaa9e8effacf4291301048ef7df03d353e">spi_order_t</a></div><div class="ttdeci">spi_order_t</div><div class="ttdoc">Enumeration of SPI bit-order values.</div><div class="ttdef"><b>Definition:</b> spi.h:157</div></div>
<div class="ttc" id="agroup__hardware__spi_html_gabb840d4e3db64ea70fad6bb740717910"><div class="ttname"><a href="group__hardware__spi.html#gabb840d4e3db64ea70fad6bb740717910">spi_write_read_blocking</a></div><div class="ttdeci">int spi_write_read_blocking(spi_inst_t *spi, const uint8_t *src, uint8_t *dst, size_t len)</div><div class="ttdoc">Write/Read to/from an SPI device.</div></div>
<div class="ttc" id="agroup__hardware__spi_html_gacff6be19b2de92a34b295597f3ae8572"><div class="ttname"><a href="group__hardware__spi.html#gacff6be19b2de92a34b295597f3ae8572">spi_write16_blocking</a></div><div class="ttdeci">int spi_write16_blocking(spi_inst_t *spi, const uint16_t *src, size_t len)</div><div class="ttdoc">Write to an SPI device.</div></div>
<div class="ttc" id="agroup__hardware__spi_html_gad3b96ae828fec8af4b0617db7e904019"><div class="ttname"><a href="group__hardware__spi.html#gad3b96ae828fec8af4b0617db7e904019">spi_write16_read16_blocking</a></div><div class="ttdeci">int spi_write16_read16_blocking(spi_inst_t *spi, const uint16_t *src, uint16_t *dst, size_t len)</div><div class="ttdoc">Write/Read half words to/from an SPI device.</div></div>
<div class="ttc" id="agroup__hardware__spi_html_gaf0c3a38c80cf84a80602755d7bac77e2"><div class="ttname"><a href="group__hardware__spi.html#gaf0c3a38c80cf84a80602755d7bac77e2">spi_deinit</a></div><div class="ttdeci">void spi_deinit(spi_inst_t *spi)</div><div class="ttdoc">Deinitialise SPI instances.</div><div class="ttdef"><b>Definition:</b> spi.c:36</div></div>
<div class="ttc" id="apico_8h_html"><div class="ttname"><a href="pico_8h.html">pico.h</a></div></div>
<div class="ttc" id="arp2__common_2hardware__spi_2include_2hardware_2spi_8h_html_a9b7b2428cfc34b20c3857980811b51a9"><div class="ttname"><a href="rp2__common_2hardware__spi_2include_2hardware_2spi_8h.html#a9b7b2428cfc34b20c3857980811b51a9">spi_inst_t</a></div><div class="ttdeci">struct spi_inst spi_inst_t</div><div class="ttdoc">Opaque type representing an SPI instance.</div><div class="ttdef"><b>Definition:</b> spi.h:51</div></div>
<div class="ttc" id="astructspi__hw__t_html"><div class="ttname"><a href="structspi__hw__t.html">spi_hw_t</a></div><div class="ttdef"><b>Definition:</b> spi.h:26</div></div>
</div><!-- fragment --></div><!-- contents -->
</div><!-- doc-content -->

	<script src="main.js"></script>
</body>
</html>